package com.xiao.controller;

import com.xiao.domain.ResponseResult;
import com.xiao.service.OssUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Api(tags = "文件上传-控制层")
public class UploadController {

    @Autowired
    private OssUploadService ossUploadService;

    @PostMapping("/upload")
    @ApiOperation(value = "上传图片",notes = "上传图片,返回访问图片 外网路径")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "img",value = "上传的文件,MultipartFile")
    })
    public ResponseResult uploadImg(MultipartFile img){
        ResponseResult result = ossUploadService.uploadImg(img);
        return result;
    }
}
